package com.yanqu.road.entity.crossorewar;

import com.alibaba.fastjson.JSON;
import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.entity.player.UserPatrons;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

public class CrossUserOrePit {

	private int activityId;

	private int pitId;

	private int stationId;

	private long userId;

	private long serverId;

	private String nickName;

	private String patronsInfoStr;

	//直接本服算好了美女技能加成
	private int beautySkillAddition;
	//直接本服算好了门客技能加成
	private int patronsSkillAddition;

	//本來是用來判断占领时间来决定谁先冠名的，现在没用了
	private long joinTime;

	private long lastGetRewardTime;

	//是否是井喷的点
	private boolean isBlowout;

	//是否是冠名的，临时缓存的
	private boolean isNaming;

	private int groupId;

	private UserBaseInfo userBaseInfo = new UserBaseInfo();            //玩家基础信息


	private BigInteger totalAbility = BigInteger.ZERO;           //总能力

	private List<UserPatrons> patronsList = new ArrayList<>();

	public int getActivityId() {
		return activityId;
	}

	public void setActivityId(int activityId) {
		this.activityId = activityId;
	}

	public int getPitId() {
		return pitId;
	}

	public void setPitId(int pitId) {
		this.pitId = pitId;
	}

	public int getStationId() {
		return stationId;
	}

	public void setStationId(int stationId) {
		this.stationId = stationId;
	}

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}


	public long getServerId() {
		return serverId;
	}

	public void setServerId(long serverId) {
		this.serverId = serverId;
	}

	public String getPatronsInfoStr() {
		return patronsInfoStr;
	}

	public void setPatronsInfoStr(String patronsInfoStr) {
		this.patronsInfoStr = patronsInfoStr;
		this.patronsList = JSON.parseArray(patronsInfoStr,UserPatrons.class);
	}

	public int getBeautySkillAddition() {
		return beautySkillAddition;
	}

	public void setBeautySkillAddition(int beautySkillAddition) {
		this.beautySkillAddition = beautySkillAddition;
	}

	public int getPatronsSkillAddition() {
		return patronsSkillAddition;
	}

	public void setPatronsSkillAddition(int patronsSkillAddition) {
		this.patronsSkillAddition = patronsSkillAddition;
	}

	public long getJoinTime() {
		return joinTime;
	}

	public void setJoinTime(long joinTime) {
		this.joinTime = joinTime;
	}

	public long getLastGetRewardTime() {
		return lastGetRewardTime;
	}

	public void setLastGetRewardTime(long lastGetRewardTime) {
		this.lastGetRewardTime = lastGetRewardTime;
	}


	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	public boolean isBlowout() {
		return isBlowout;
	}

	public void setBlowout(boolean blowout) {
		isBlowout = blowout;
	}

	public boolean isNaming() {
		return isNaming;
	}

	public void setNaming(boolean naming) {
		isNaming = naming;
	}

	public BigInteger getTotalAbility() {
		return totalAbility;
	}

	public void setTotalAbility() {
		BigInteger tempTotalAbility = BigInteger.ZERO;
		for (UserPatrons userPatrons : patronsList){
			tempTotalAbility = tempTotalAbility.add(userPatrons.getAbility());
		}
		this.totalAbility = tempTotalAbility;
	}

	public List<UserPatrons> getPatronsList() {
		return patronsList;
	}

	public void setPatronsList(List<UserPatrons> patronsList) {
		this.patronsList = patronsList;
	}

	public boolean isContainsPatrons(int patronsId){
		UserPatrons userPatrons = getUserPatrons(patronsId);
		return null != userPatrons;
	}

	public void addUserPatrons(UserPatrons userPatrons){
		replacePatrons(userPatrons);
	}

	public void replacePatrons(UserPatrons userPatrons){
		UserPatrons oldPatrons = getUserPatrons(userPatrons.getPatronsId());
		if(null != oldPatrons) {
			patronsList.remove(oldPatrons);
		}
		patronsList.add(userPatrons);
	}

	public UserPatrons getUserPatrons(int patronsId){
		for(UserPatrons userPatrons : patronsList){
			if(userPatrons.getPatronsId() == patronsId){
				return userPatrons;
			}
		}
		return null;
	}

	public UserBaseInfo getUserBaseInfo() {
		return userBaseInfo;
	}

	public String getUserBaseInfoJsonStr(){
		if(null == userBaseInfo){
			return "{}";
		}else {
			return JSON.toJSONString(userBaseInfo);
		}
	}

	public void setUserBaseInfo(UserBaseInfo userBaseInfo) {
		this.userBaseInfo = userBaseInfo;
	}

	public int getGroupId() {
		return groupId;
	}

	public void setGroupId(int groupId) {
		if (this.groupId != groupId){
			this.groupId = groupId;

		}
	}
}
